package com.corpgovernment.permission.config;


import com.corpgovernment.common.handler.ICacheHandler;
import com.corpgovernment.common.utils.DataPermissions.DataPermissionsConfig;
import com.corpgovernment.redis.cache.RoleResourceManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author ：xks
 * @date ：Created in 2022/7/20 10:19
 * @description：
 * @modified By：
 * @version: $
 */
@Slf4j
@Component
public class RoleResourceManagerExt {

    //根据角色ID获取资源数据
    private static final String ROLE_KEY = DataPermissionsConfig.ROLE_KEY;

    @Resource
    private ICacheHandler cacheHandler;

    /**
     * 删除角色相关数据权限缓存
     */
    public void delResource(String key) {
        cacheHandler.delete(getKey(key));
    }


    public String getKey(String key){
        return String.format(ROLE_KEY, key);
    }


}
